//
//  LQYPasswordLoginView.m
//  BuDeJie
//
//  Created by runone02 on 2018/6/15.
//  Copyright © 2018年 李启云. All rights reserved.
//

#import "LQYPasswordLoginView.h"

@interface LQYPasswordLoginView ()<UITextFieldDelegate>

@end
@implementation LQYPasswordLoginView


- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    self.iconImage = [[UIImageView alloc]init];
    self.iconImage.backgroundColor = [UIColor redColor];
    [self addSubview: self.iconImage];
    
    [self.iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).with.offset(20);
        make.top.mas_equalTo(self).with.offset(10);
        make.width.height.mas_equalTo(20);
    }];
    
    self.loginNameTF = [[UITextField alloc]init];
    self.loginNameTF.placeholder = @"输入手机号";
    self.loginNameTF.keyboardType = UIKeyboardTypeNumberPad;
    self.loginNameTF.delegate = self;
    self.loginNameTF.textColor = [UIColor lightGrayColor];
    [self addSubview:self.loginNameTF];
    
    [self.loginNameTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.iconImage);
        make.left.mas_equalTo(self.iconImage.mas_right).with.offset(10);
        make.height.mas_equalTo(30);
        make.right.mas_equalTo(self).with.offset(-20);
    }];
    
    self.lineOneView = [[UIView alloc]init];
    self.lineOneView.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:self.lineOneView];
    
    [self.lineOneView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.loginNameTF.mas_bottom).with.offset(3);
        make.left.mas_equalTo(self.iconImage);
        make.right.mas_equalTo(self.loginNameTF);
        make.height.mas_equalTo(1);
    }];
    
    self.passWordIcon = [[UIImageView alloc]init];
    self.passWordIcon.backgroundColor = [UIColor yellowColor];
    [self addSubview:self.passWordIcon];
    
    [self.passWordIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).with.offset(20);
        make.top.mas_equalTo(self.lineOneView.mas_bottom).with.offset(20);
        make.width.height.mas_equalTo(20);
    }];
    
    self.passWordTF = [[UITextField alloc]init];
    self.passWordTF.placeholder = @"输入密码";
    self.passWordTF.delegate = self;
    self.passWordTF.secureTextEntry = YES;
    self.passWordTF.keyboardType = UIKeyboardTypeASCIICapable;
    self.passWordTF.textColor = [UIColor lightGrayColor];
    [self addSubview:self.passWordTF];
    
    [self.passWordTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.passWordIcon);
        make.left.mas_equalTo(self.passWordIcon.mas_right).with.offset(10);
        make.height.mas_equalTo(30);
        make.right.mas_equalTo(self).with.offset(-20);
    }];
    
    self.lineTwoView = [[UIView alloc]init];
    self.lineTwoView.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:self.lineTwoView];
    
    [self.lineTwoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.passWordTF.mas_bottom).with.offset(3);
        make.left.mas_equalTo(self.passWordIcon);
        make.right.mas_equalTo(self.passWordTF);
        make.height.mas_equalTo(1);
    }];
    
    self.isVisual = [[UIButton alloc]init];
    self.isVisual.backgroundColor = [UIColor redColor];
    
    [self.passWordTF addSubview:self.isVisual];
    [self.isVisual mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.passWordIcon);
        make.right.mas_equalTo(self).with.offset(-20);
        make.width.height.mas_equalTo(20);
        
    }];
    
    self.forgetPassWord = [[UIButton alloc]init];
    [self.forgetPassWord setTitle:@"忘记密码?" forState:UIControlStateNormal];
    [self.forgetPassWord setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    
    self.forgetPassWord.titleLabel.font = TITLE_FONT(32);
    [self addSubview:self.forgetPassWord];
    
    [self.forgetPassWord mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self.lineTwoView.mas_bottom).with.offset(W_RATIO(30));
    }];
    
    self.loginBtn = [[UIButton alloc]init];
    self.loginBtn.backgroundColor = [UIColor redColor];
    [self.loginBtn setTitle:@"登录" forState:UIControlStateNormal];
    [self.loginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    [self.loginBtn.layer setMasksToBounds:YES];
    [self.loginBtn.layer setCornerRadius:8.0];
    [self.loginBtn.layer setBorderWidth:1.0];
    self.loginBtn.layer.borderColor = [UIColor blackColor].CGColor;
    [self addSubview:self.loginBtn];
    
    [self.loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.forgetPassWord.mas_bottom).with.offset(20);
        make.left.mas_equalTo(self).with.offset(30);
        make.right.mas_equalTo(self).with.offset(-30);
        make.height.mas_equalTo(40);
    }];
    
    self.enrollBtn = [[UIButton alloc]init];
    [self.enrollBtn setTitle:@"点击注册" forState:UIControlStateNormal];
    [self.enrollBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    
    self.enrollBtn.titleLabel.font = TITLE_FONT(32);
    [self addSubview:self.enrollBtn];
    
    [self.enrollBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self.loginBtn.mas_bottom).with.offset(W_RATIO(25));
        make.left.mas_equalTo(self);
        make.right.mas_equalTo(self);
        make.width.mas_equalTo(20);
    }];
    self.authorizedLoginBtn = [[UIButton alloc]init];
    self.authorizedLoginBtn.backgroundColor = [UIColor blackColor];
   
    [self addSubview:self.authorizedLoginBtn];
    
    [self.authorizedLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self).with.offset(10);
        make.centerX.mas_equalTo(self);
        make.width.height.mas_equalTo(30);
    }];
    
    self.authorizedLoginLabel = [[UILabel alloc]init];
    self.authorizedLoginLabel.text = @"授权登录";
    self.authorizedLoginLabel.textColor = [UIColor grayColor];
    [self addSubview:self.authorizedLoginLabel];
    
    [self.authorizedLoginLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.bottom.mas_equalTo(self.authorizedLoginBtn.mas_top).with.offset(-20);
    }];
    
    self.laftView = [[UIView alloc]init];
    self.laftView.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:self.laftView];
    
    [self.laftView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.authorizedLoginLabel);
        make.left.mas_equalTo(self).with.offset(20);
        make.height.mas_equalTo(0.5);
        make.right.mas_equalTo(self.authorizedLoginLabel.mas_left).with.offset(-10);
    }];
    
    self.rightView = [[UIView alloc]init];
    self.rightView.backgroundColor = [UIColor lightGrayColor];
    [self addSubview: self.rightView];
    
    [self.rightView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.authorizedLoginLabel);
        make.left.mas_equalTo(self.authorizedLoginLabel.mas_right).with.offset(10);
        make.right.mas_equalTo(self).with.offset(-10);
        make.height.mas_equalTo(0.5);
    }];
}



@end
